﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using T4ViewModel.Test.ViewModels;

namespace T4ViewModel.Test
{
    [TestClass]
    public class ConversionsTest
    {
        [TestMethod]
        public void ConvertFromModelTest()
        {
            var model = new BlogPostModel()
            {
                Author = new PersonModel() { FirstName = "Janusz", LastName = "Kowalski" },
                Body = "Post text",
                Title = "Post title",
                Comments = new List<CommentModel>()
            };

            var viewModel = new PersonPostViewModel(model);

            Assert.AreEqual(model.Title, viewModel.Title);
            Assert.AreEqual(model.Author, viewModel.Author);
        }

        [TestMethod]
        public void ConvertToModelTest()
        {
            var viewModel = new PersonNameViewModel()
            {
                FirstName = "Janusz",
                LastName = "Kowalski"
            };

            var model = viewModel.ToModel();

            Assert.AreEqual(model.FirstName, viewModel.FirstName);
            Assert.AreEqual(model.LastName, viewModel.LastName);
            Assert.IsNull(model.Posts);
        }
    }
}
